package com.qingcloud.adminbackend.entity.usergroup;

import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.StringUtils;

/**
 * <p>
 * 新用户组
 * </p>
 *
 * @author wangjinnan
 * @since 2018-11-15
 */
@Data
public class SysUsergroupUserParam extends Model<SysUsergroupUserParam> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "用户组ID", required = true)
    private String groupId;

    @ApiModelProperty(value = "查询关键字，姓名，手机号或登录名", example = "admin")
    private String keyword;

    @ApiModelProperty(value = "当前第几页，从1开始", example = "1")
    private Integer currentPage = 1;

    @ApiModelProperty(value = "每页多少条", example = "100000000")
    private Integer perPage = 100000000;

    @ApiModelProperty(value = "mybatis plus分页对象", hidden = true)
    private Page page;

    public String getKeyword() {
        if (!StringUtils.isEmpty(keyword) && keyword.trim().length() > 0) {
            return "%" + keyword + "%";
        }
        return null;
    }

    public Page getPage() {
        if (currentPage != null && perPage != null) {
            return new Page(currentPage, perPage);
        }
        return null;
    }
}
